package com.main;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.xml.parsers.FactoryConfigurationError;

import com.restfb.Connection;
import com.restfb.FacebookClient;
import com.restfb.types.Event;
import com.restfb.types.Post;


public class Events {
	private List<EventObject> eventObjectList;
	//ID, Name, Time, 
	public Events(FacebookClient facebookClient){
		Connection<Event> events = facebookClient.fetchConnection("me/events", Event.class);
		List<Event> eventList = events.getData();
		eventObjectList = new ArrayList<EventObject>();
		for( Event event : eventList){
			EventObject e = new EventObject(event.getId(), event.getName(), event.getStartTime());
			eventObjectList.add(e);
		}
	}
	/**
	 * Method to get list of Events
	 * @return
	 */
	public List<EventObject> getEventList(){
		return eventObjectList;
	}
	
	/**
	 * Method to get Event by eventId
	 * @param id
	 * @return
	 */
	public EventObject getEventById(String id){
		if(id!=null)
		for(EventObject event : eventObjectList){
			if(id.equals(event.getId())){
				return event;
			}
		}
		return null;
	}
}
